<template>
	<view class="nav-bar" :style="{background: bgc, paddingTop: top}">
		<!-- <view class="status-bar"> </view> -->
		<view class="nav">
			<view class="left"> 
				<image src="/static/icon/navbar/left.png" class="left" @tap="leftTap"/>
			</view>
			<view class="center"> {{ title }} </view>
			<view class="right">
				<!-- #ifndef MP-WEIXIN -->
				<image v-if="right" src="/static/icon/rider/message.png" @tap="rightTap" class="r-img"/>
				<!-- #endif -->
			</view>
		</view>
		<view class="home-tips" v-if="tips"> 您有新的派单，请及时结束后或拒绝({{tips}}) </view>
	</view>
</template>

<script setup>
  import { computed } from 'vue'
	defineProps({
		title: String,
		right: {
			type: Boolean,
			default: true
		},
		tips: {
			type: Number,
			default: 0
		},
		bgc: {
			type: String,
			default: 'linear-gradient( 180deg, #FFEFED 0%, #FFFFFF 98%)'
		}
	})
	const emit = defineEmits([ 'leftTap', 'rightTap' ])
  const { statusBarHeight } = uni.getSystemInfoSync()
  const top = computed(() => statusBarHeight + 'px')
	const rightTap = () => {
		emit('rightTap')
	}
	const leftTap = () => {
		uni.navigateBack()
	}
</script>

<style lang="scss" scoped>
	.nav-bar {
		position: sticky;
		z-index: 999;
		top: 0;
		left: 0;
		right: 0;
		background: linear-gradient( 180deg, #FFEFED 0%, #FFFFFF 98%);
		.status-bar {
			height: var(--status-bar-height);
			width: 100%;
		}
		.nav {
			height: 44px;
			padding: 0 12px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left {
				width: 16px;
				height: 16px;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.center {
				font-size: 17px;
				font-weight: 500;
			}
			.right {
				width: 20px;
				height: 20px;
				.r-img {
					width: 20px;
					height: 20px;
				}
			}
		}
		.home-tips {
			width: 100%;
			height: 28px;
			color: #FF7D00;
			font-size: 14px;
			font-weight: 400;
			line-height: 28px;
			text-align: center;
			background: #FFF7E8;
		}
	}
</style>